import Api from "@/api/operations/events";
import i18n from "@/lang/index";
const modalConfig = {
  pageName: 'sys:user',
  dialog: {
    title: i18n.global.t('title.24'),
    width: 1100,
    appendToBody: true,
    draggable: true,
    labelWidth: "auto",
  },
  formAction: (data) => {
    console.log('edit', data)
    return new Promise((resolve, reject) => {
      Api.put(data).then((s) => {
        console.log(s)
        resolve(s)
      }).catch((e) => {
        reject(e)
      })
    })
  },
  formItems:  [
    {
      type: "input",
      label: "ID",
      prop: "id",
      attrs: {
        disabled: true
      },
      hidden: true,
    },
    {
      type: "input",
      label: i18n.global.t("label.99"),
      prop: "title",
      attrs: {
        placeholder: i18n.global.t("hint.105"),
      },
    },
    {
      type: "custom",
      label: i18n.global.t("label.63"),
      prop: "type",
      attrs: {
        placeholder: i18n.global.t("hint.69"),
      }
    },
    {
      type: "custom",
      label: i18n.global.t("label.153"),
      prop: "metadata",
      col: {
        span: 24,
      }
    },
    {
      type: "custom",
      label: i18n.global.t("label.62"),
      prop: "image",
      attrs: {
        placeholder: i18n.global.t("hint.106"),
      },
    },
    {
      type: "date-picker",
      label: i18n.global.t("label.59"),
      prop: "started_at",
      attrs: {
        type: "datetime",
        placeholder: i18n.global.t("label.59"),
        format: "YYYY-MM-DD HH:mm:ss",
        'date-format': "YYYY/MM/DD ddd",
        'time-format': "HH:mm:ss",
      },
    },
    {
      type: "date-picker",
      label: i18n.global.t("form.55"),
      prop: "ended_at",
      attrs: {
        type: "datetime",
        placeholder: i18n.global.t("form.55"),
        format: "YYYY-MM-DD HH:mm:ss",
        'date-format': "YYYY/MM/DD ddd",
        'time-format': "HH:mm:ss",
      },
    },
    {
      type: "radio",
      label: i18n.global.t("label.105"),
      prop: "visible",
      options: [
        { label: i18n.global.t("status.1"), value: true },
        { label: i18n.global.t("status.2"), value: false },
      ],
      initialValue: true,
      col: {
        span: 12,
      }
    },
    {
      type: "select",
      label: i18n.global.t("label.23"),
      prop: "status",
      attrs: {
        placeholder: i18n.global.t("hint.150"),
      },
      options:[
        { label: i18n.global.t("status.48"), value: 'active'},
        { label: i18n.global.t("status.49"), value: 'inactive' },
      ]
    },
    {
      type: "input",
      label: i18n.global.t("form.12"),
      prop: "sort",
      attrs: {
        placeholder: i18n.global.t("hint.24"),
      }
    },
    {
      type: "editor",
      label: i18n.global.t("label.166"),
      prop: "content",
    },
  ],
  formRules: {
    title: [{ required: true, message: i18n.global.t("hint.105"), trigger: "blur" }],
    image: [{ required: true, message: i18n.global.t("hint.106"), trigger: "blur" }],
    sort: [{ required: true, message: i18n.global.t("hint.24"), trigger: "blur" }],
    type: [{ required: true, message: i18n.global.t("hint.69"), trigger: ['change','blur'] }],
    status: [{ required: true,message: i18n.global.t("hint.150"), trigger: ['change','blur'] }],
    started_at: [
      { required: true, message: i18n.global.t("hint.151"), trigger: ['change','blur'] },
    ],
    ended_at: [
      { required: true, message: i18n.global.t("hint.152"), trigger: ['change','blur'] },
    ],
  },
}

export default modalConfig
